using System;
using System.Collections.Generic;
using System.Text;
using CodeStory.Core.ObjectEntity;

namespace CodeStory.Core.ObjectBusiness
{
	public sealed class PageBusiness
	{
		private PageBusiness() {

		}

		public static Guid InsertPage(string name, string title, string description, Guid layoutID) {
			PageObject page = PageObject.New();
			page.PageID = Guid.NewGuid();
			page.PageName = name;
			page.Title = title;
			page.Description = description;
			page.LayoutID = layoutID;
			page.Save();

			ResourceBusiness.InsertResource(page.PageID.ToString(), Guid.Empty, page.Title, string.Empty, "page");

			return page.PageID;
		}

		public static Guid UpdatePage(Guid pageID, string name, string title, string description, Guid layoutID) {
			PageObject page = PageObject.Read(pageID);
			//page.PageID = Guid.NewGuid();
			page.PageName = name;
			page.Title = title;
			page.Description = description;
			page.LayoutID = layoutID;
			page.Save();
			return page.PageID;
		}
	}
}
